import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'
import WapLayout from '../views/layout/WapLayout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', name: 'Login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },
  {
    path: '/setting',
    component: Layout,
    meta: {
      // top: true,
      title: '在线监测',
      icon: 'my-jiance'
    },
    children: [
      // {
      //   path: '/setting',
      //   name: 'Setting',
      //   component: () => import('@/views/setting/index'),
      //   meta: {
      //     title: '系统设置',
      //     icon: 'my-yuanquan'
      //   }
      // },
      // {
      //   path: '/nav',
      //   name: 'Nav',
      //   component: () => import('@/views/setting/nav'),
      //   meta: {
      //     title: '导航管理',
      //     icon: 'my-yuanquan'
      //   }
      // },
      {
        path: '/realtime-data',
        name: 'Realtime',
        component: () => import('@/views/dataView/realtime'),
        meta: {
          title: '实时数据',
          icon: 'my-yuanquan'
        }
      },
      {
        path: '/warn',
        name: 'Warn',
        component: () => import('@/views/dataView/warn'),
        meta: {
          title: '告警事件',
          icon: 'my-yuanquan'
        }
      },
      {
        path: '/mapdemo',
        name: 'mapdemo',
        component: () => import('@/views/map/demo'),
        meta: {
          title: '地图概览',
          icon: 'my-yuanquan'
        }
      }
    ]
  },
  {
    path: '/dataView',
    component: Layout,
    meta: {
      // top: true,
      title: '统计分析',
      icon: 'my-shebei'
    },
    children: [
      {
        path: '/history',
        name: 'History',
        component: () => import('@/views/dataView/history'),
        meta: {
          title: '历史数据',
          icon: 'my-yuanquan'
        }
      },
      {
        path: '/alarmAnalysis',
        name: 'AlarmAnalysis',
        component: () => import('@/views/dataView/alarmAnalysis'),
        meta: {
          title: '告警分析',
          icon: 'my-yuanquan'
        }
      }
    ]
  },
  {
    path: '/isp',
    component: Layout,
    meta: {
      // top: true,
      title: '单位管理',
      icon: 'my-qiye'
    },
    children: [
      {
        path: '/isp',
        name: 'Isp',
        component: () => import('@/views/isp/index'),
        meta: {
          title: '单位管理',
          icon: 'my-yuanquan'
        }
      },
      {
        path: '/isp-add',
        name: 'IspAdd',
        component: () => import('@/views/isp/add'),
        hidden: true,
        meta: {
          title: '新增单位',
          icon: 'my-yuanquan'
        }
      },
      {
        path: '/device',
        name: 'Device',
        component: () => import('@/views/device/index'),
        meta: {
          title: '测点管理',
          icon: 'my-yuanquan'
        }
      },
      {
        path: '/device-setting',
        name: 'DeviceSetting',
        component: () => import('@/views/device/setting'),
        hidden: true,
        meta: {
          title: '测点配置',
          icon: 'my-yuanquan'
        }
      }
    ]
  },
  // {
  //   path: '/account',
  //   component: Layout,
  //   meta: {
  //     title: '账户管理',
  //     icon: 'user'
  //   },
  //   children: [
  //     {
  //       path: '/account/addUser',
  //       name: 'AccountAddUser',
  //       component: () => import('@/views/account/addUser'),
  //       meta: {
  //         title: '添加用户',
  //         icon: 'user'
  //       }
  //     },
  //     {
  //       path: '/account/password',
  //       name: 'AccountPassword',
  //       component: () => import('@/views/account/password'),
  //       meta: {
  //         title: '修改密码',
  //         icon: 'password'
  //       }
  //     },
  //     {
  //       path: '/account/accountList',
  //       name: 'AccountList',
  //       component: () => import('@/views/account/accountList'),
  //       meta: {
  //         title: '账户列表',
  //         icon: 'user'
  //       }
  //     }
  //   ]
  // },
  // WAP端
  {
    path: '/wap',
    component: WapLayout,
    hidden: true,
    meta: {
      top: true,
      title: 'WAP端'
    },
    children: [
      {
        path: '/wap/reallist',
        name: 'WapReallist',
        component: () => import('@/views/wap/reallist'),
        meta: {
          title: '实时监测'
        }
      }
    ]
  }
]

export default new Router({
  // mode: 'history', // 后端支持可开
  scrollBehavior: () => ({ y: 0 }), // 回到顶部
  routes: constantRouterMap
})
